<template>
  <div class="Previe-dialog">
    <el-dialog :visible.sync="visible" :append-to-body="true">
      <div class="PreviewImage flex">
        <el-image :src="previewUrl" :lazy="lazy" :fit="fit" class="pre-img" />
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'PreviewImage',
  props: {
    value: {
      type: Boolean
    },
    previewUrl: {
      type: String,
      default: ''
    },
    lazy: {
      type: Boolean,
      default: true
    },
    fit: {
      type: String,
      default: 'fill'
    }
  },
  data() {
    return {
      visible: false
    }
  },
  watch: {
    visible(v) {
      this.$emit('input', v)
    },
    value(v) {
      this.visible = v
    }
  }
}
</script>

<style lang="scss">
@import "@/styles/public.scss";

// .PreviewImage {
  .PreviewImage {
    width: 850px;
    height: 900px;
    margin: -100px 0 0 -150px;
    border-radius: 5px;
    .pre-img {
      width: 100%;
      height: 100%;
      border-radius: 5px;
      // background: #ffffff;
    }
    // .el-image__error {
    //   width: 800px;
    //   height: 600px;
    //   background: #ffffff;
    // }
  }
// }
</style>
